package com.dg.acb.utils.xml;

import android.os.Bundle;

abstract class ABaseTag implements XmlTag{
    private final String mName;
    private final String mValue;
    private final Bundle mAttributes = new Bundle();

    protected ABaseTag(String name, String value) {
        super();
        this.mName = name;
        this.mValue = value;
    }

    @Override
    public String getName() {
        return mName;
    }

    @Override
    public String getValue() {
        return mValue;
    }

    @Override
    public void recycle() {
        mAttributes.clear();
    }

    @Override
    public Bundle getAttributes() {
        return mAttributes;
    }

    @Override
    public void addAttributes(Bundle bundle) {
        mAttributes.putAll(bundle);
    }

    @Override
    public void addAttribute(String name, String value) {
        mAttributes.putString(name, value);
    }

    @Override
    public void addAttributeResource(String name, int value) {
        mAttributes.putInt(name, value);
    }

    @Override
    public String getAttribute(String name, String defVaule) {
        if (mAttributes.containsKey(name)) {
            return mAttributes.getString(name);
        }
        return defVaule;
    }

    @Override
    public int getAttributeResourceValue(String name, int defVaule) {
        if (mAttributes.containsKey(name)) {
            return mAttributes.getInt(name);
        }
        return defVaule;
    }
}
